﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WeiXinSDK.DataModel.Enum;

namespace WeiXinSDK.DataModel
{
    public class RequestXML
    {

        private string appCode;
        /// <summary>
        /// 应用编号，在多公众号配置的环境下用作唯一标识
        /// </summary>
        public string AppCode
        {
            get { return appCode; }
            set { appCode = value; }
        }

        private string toUserName = "";
        /// <summary>
        /// 消息接收方微信号，一般为公众平台账号微信号
        /// </summary>
        public string ToUserName
        {
            get { return toUserName; }
            set { toUserName = value; }
        }

        private string fromUserName = "";
        /// <summary>
        /// 消息发送方微信号
        /// </summary>
        public string FromUserName
        {
            get { return fromUserName; }
            set { fromUserName = value; }
        }

        private string createTime = "";
        /// <summary>
        /// 创建时间
        /// </summary>
        public string CreateTime
        {
            get { return createTime; }
            set { createTime = value; }
        }

        private string msgType = "";
        /// <summary>
        /// 信息类型 地理位置：location，文本消息：text，消息类型：image，语音类型：Voice，视频类型：Video，链接类型：Link，事件类型：event
        /// </summary>
        public string MsgType
        {
            get { return msgType; }
            set { msgType = value; }
        }

        /// <summary>
        /// 信息类型 地理位置：location，文本消息：text，消息类型：image，语音类型：voice，视频类型：video，链接类型：link，事件类型：event
        /// </summary>
        public RequestMsgType RequestMsgType
        {
            get
            {
                return (RequestMsgType)System.Enum.Parse(typeof(RequestMsgType), this.MsgType, true);
            }
        }

        private string _event = string.Empty;
        /// <summary>
        /// 事件类型 用户关注：subscribe，取消关注：unsubscribe，模板消息发送后返回：TEMPLATESENDJOBFINISH
        /// </summary>
        public string Event
        {
            get { return _event; }
            set { _event = value; }
        }

        private string _eventKey = string.Empty;
        /// <summary>
        /// 事件key值
        /// </summary>
        public string EventKey
        {
            get { return _eventKey; }
            set { _eventKey = value; }
        }

        private string _msgID = string.Empty;
        /// <summary>
        /// 模版消息id 
        /// </summary>
        public string MsgID
        {
            get { return _msgID; }
            set { _msgID = value; }
        }

        private string _status = string.Empty;
        /// <summary>
        /// 模版消息发送状态。success 成功；failed:user block 用户拒收；failed: system failed 其他原因发送失败（非用户拒绝） 
        /// </summary>
        public string Status
        {
            get { return _status; }
            set { _status = value; }
        }

        private string content = "";
        /// <summary>
        /// 信息内容
        /// </summary>
        public string Content
        {
            get { return content; }
            set { content = value; }
        }

        private string location_X = "";
        /// <summary>
        /// 地理位置纬度
        /// </summary>
        public string Location_X
        {
            get { return location_X; }
            set { location_X = value; }
        }

        private string location_Y = "";
        /// <summary>
        /// 地理位置经度
        /// </summary>
        public string Location_Y
        {
            get { return location_Y; }
            set { location_Y = value; }
        }

        private string scale = "";
        /// <summary>
        /// 地图缩放大小
        /// </summary>
        public string Scale
        {
            get { return scale; }
            set { scale = value; }
        }

        private string label = "";
        /// <summary>
        /// 地理位置信息
        /// </summary>
        public string Label
        {
            get { return label; }
            set { label = value; }
        }

        private string picUrl = "";
        /// <summary>
        /// 图片链接，开发者可以用HTTP GET获取
        /// </summary>
        public string PicUrl
        {
            get { return picUrl; }
            set { picUrl = value; }
        }

        /// <summary>
        /// 图片消息媒体id，可以调用多媒体文件下载接口拉取数据。 
        /// 语音消息媒体id，可以调用多媒体文件下载接口拉取数据。 
        /// 视频消息媒体id，可以调用多媒体文件下载接口拉取数据。 
        /// </summary>
        public string MediaId { get; set; }

        /// <summary>
        /// 语音格式，如amr，speex等 
        /// </summary>
        public string Format { get; set; }

        /// <summary>
        /// 视频消息缩略图的媒体id，可以调用多媒体文件下载接口拉取数据。 
        /// </summary>
        public string ThumbMediaId { get; set; }

        /// <summary>
        /// 格式化输出，便于输出调试信息
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (var item in this.GetType().GetProperties())
            {
                if (item.Name.Equals("Item"))
                {
                    continue;
                }
                sb.AppendFormat("{0}={1},", item.Name, item.GetValue(this, null));
            }
            return sb.ToString().TrimEnd(',');
        }
    }
}
